package me.moscrop.RootCommand.commands;

import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.player.PlayerListener;

public class Kill extends PlayerListener {
	
	
	public static boolean kill(CommandSender sender, String[] args)
	{
		Player personToKill;


		//Do they just want usage info ?
		if(args.length == 0 || (args.length == 1 && args[0].contentEquals("")))
		{
			displayHelp((Player) sender);
			return true;
		}
		
		personToKill = sender.getServer().getPlayer(args[0]);
		
		if(personToKill != null)
		{
			
			kill(personToKill);
			((Player) sender).sendMessage(ChatColor.GREEN + "Congratulations, You just killed " + args[0] +".");
			return true;
		}else{
			((Player) sender).sendMessage(ChatColor.RED + args[0] +" doesnt exist.");
			return true;
		}
	}

	private static void displayHelp(Player sender)
	{
		sender.sendMessage(ChatColor.RED + "Usage: /kill <target>");
	}
	
	private static void kill(Player player)
	{
		player.setHealth(0);
	}

	

}
